<?php

/**
 * @author HX<titanrain@163.com>
 */
class LoginForm extends CFormModel
{
	public $username;
	public $password;
	public $rememberMe;

	private $_identity;

	public function login()
	{
		if($this->_identity===null)
		{
			$this->_identity=new UserIdentity($this->username,$this->password);
		}
		if($this->_identity->authenticate()){
			$duration=$this->rememberMe ? 3600*24*180 : 0; // 180 days
			Yii::app()->user->login($this->_identity,$duration);
			return true;
		} else {
			return false;
		}
	}
}
